<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
		<link rel="stylesheet" href="static/css/bootstrap.min.css" />
		<link rel = "stylesheet" href = "static/css/globle.css"/>
	<title></title>
</head>
<body>
 <div class="navbar navbar-fixed-top" id = "manager">
			<div class="navbar-inner">
				<div class="container">
					<a  class = "brand" href="#">项目管理系统</a>
			
				</div>
			</div>
</div>
	<div class="container" style = "margin-top:60px">
		<div class="row" style = "margin-top:10px">
			<div class="span3">
				<div style="padding: 8px 0;" class="well">
					<ul class="nav nav-list">
					  <li class="nav-header">${project.p_name }</li>
					  <li class="active"><a href="project.jspx?_m=project&pid=${project.p_id }"><i class="icon-white icon-home"></i>最新动态</a></li>
					  <li><a href="goal.jspx?p_id=${project.p_id }"><i class="icon-flag"></i>目标</a></li>
					  <li><a href="material.jspx?pid=${project.p_id }"><i class="icon-folder-open"></i>资料库</a></li>
					  <li><a href ="fileShare.jspx?pid=${project.p_id }"><i class="icon-file"></i>文件共享</a></li>
					  <li><a href="contact.jspx?pid=${project.p_id }"><i class="icon-user"></i>联系人</a></li>
					  <li><a href="idear.jspx?pid=${project.p_id }"><i class="icon-fire"></i>想法</a></li>
					  <li><a href="#"><i class="icon-warning-sign"></i>Bug</a></li>
					  <li><a href="#"><i class="icon-cog"></i>项目设置</a></li>
					</ul>
				</div>
			</div>
			<div class = "span6">
				
				<form>
					<textarea rows="5" style = "width:460px;font-size:18px" placeholder="say something..." id = "content"></textarea>
					<input type = "hidden" value = "${user.m_id }" id = "member"/>
					<button class="btn btn-primary" type="button" id = "btn">发表</button>
				</form>
				<hr/>
				<h3>最新动态</h3>
				<div>
					<c:if test="${fn:length(messagePager.result) == 0 }">
						<div>还没有最新动态，赶快发表吧</div>
					</c:if>
					<div id = "result"></div>
					<c:forEach items = "${messagePager.result }" var = "mes">
						 <blockquote>
	    					<p>${mes.mes_content }</p>
	    					<small>${mes.memberName}发表于${mes.mes_createTime}之前</small>
	    				</blockquote>
    				</c:forEach>
    				<div id = "result"></div>
    				
				</div>
			</div>
			
			<div class = "span3" style = "margin-top:-20px">
			
				<ul class="breadcrumb" style = "margin-top:20px;margin-bottom:0px;border-radius:3px 3px 0 0;">
						<li>我的任务</li>
				</ul>
				
				<div class = "well" style = "border-radius:0 0 3px 3px">
					<ul style = "font-size:15px">
						<c:forEach items = "${memberTask}" var = "mtask">
							<li style = "margin-top:5px"> ${mtask.t_name }</li>
						</c:forEach>
						
					</ul>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		var xmlHttp;
		
		function createXMLHttp() {
			if(window.ActiveXObject) {
	    		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    	} else {
	    		xmlHttp = new XMLHttpRequest();
	    	}
		}
	
  		document.getElementById("btn").onclick=function(){
  			createXMLHttp();
  			
  			var content = document.getElementById("content").value;
  			document.getElementById("content").value = "";
  			//alert(content);
  			var memberid = document.getElementById("member").value;
  			
  			if(content.trim() != "") {
	  			xmlHttp.open("post", "message.jspx", true);
	  			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	  			xmlHttp.onreadystatechange = callback;
	  			xmlHttp.send("_m="+"insert"+"&mid="+memberid+"&content="+content);
  			}
  			
  			
  		};
  		
  		function callback(){
			if(xmlHttp.readyState == 4) {
				if(xmlHttp.status == 200) {
				//接受返回的json数据
				
					var obj = JSON.parse(xmlHttp.responseText);
					//alert(obj.memberName);
					
					var block = document.createElement("blockquote");
					var small = document.createElement("small");
					var p = document.createElement("p");
					
					var content = document.createTextNode(obj.mes_content);
					var smallContent = document.createTextNode(obj.memberName+"发布于"+obj.mes_createTime+"之前");
					
					p.appendChild(content);
					small.appendChild(smallContent);
					
					block.appendChild(p);
					block.appendChild(small);
					document.getElementById("result").appendChild(block);
					
					
					
						
						
					}
					
				}
			}
  		
	</script>
</body>
</html>